<?php
class Default_Form_Item extends Zend_Form
{

    public function init()
    {
        $itemName = new Zend_Form_Element_Text('itemName');
        $itemName->setLabel('Tên')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidators(array( 
                                        array('NotEmpty',true,array('messages' => 'Tên items không được để trống')),
                                        ));
        $itemName->setAttrib('size', 51);
        
        $category = new Zend_Form_Element_Select('category');
        $category->setLabel('Nhóm thiết bị *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $category->setAttrib('style', 'width: 200px');
      	$model_category = new Default_Model_CategoryItem();
        $categories = $model_category->getAllData();
        foreach($categories as $c)
        	$category->addMultiOption($c->categoryItemId,$c->categoryItemName);
        
        $code = new Zend_Form_Element_Text('code');
        $code->setLabel('Mã quản lý *')->addFilter('StripTags')->addFilter('StringTrim');
        $code->setAttrib('size', 51);
        $code->setAttrib('readonly', 'readonly');
        
        $serialNumber = new Zend_Form_Element_Text('serialNumber');
        $serialNumber->setLabel('Serial number')->addFilter('StripTags')->addFilter('StringTrim');
        $serialNumber->setAttrib('size', 51);
        
        $priceItem = new Zend_Form_Element_Text('priceItem');
        $priceItem->setLabel('Giá Mua')->addFilter('StripTags')->addFilter('StringTrim')
                ->removeDecorator('HtmlTag');
           
        $priceItem->setAttrib('size', 51);
        
        
        $rentItem = new Zend_Form_Element_Text('rentItem');
        $rentItem->setLabel('Giá Thuê')->addFilter('StripTags')->addFilter('StringTrim')
                ->removeDecorator('HtmlTag');
        $rentItem->setAttrib('size', 51);
        
        $priceNow = new Zend_Form_Element_Text('priceNow');
        $priceNow->setLabel('Giá Hiện Tại')->addFilter('StripTags')->addFilter('StringTrim')
                ->removeDecorator('HtmlTag');
        $priceNow->setAttrib('size', 51);
        
        $rentEnd = new Zend_Form_Element_Text('rentEnd');
        $rentEnd->setLabel('Giá Sau Hợp Đồng')->addFilter('StripTags')->addFilter('StringTrim')
                ->removeDecorator('HtmlTag');       
        $rentEnd->setAttrib('size', 51);
        
        $startDate = new Zend_Form_Element_Text('startDate');
        $startDate->setLabel('Ngày Bắt Đầu')->addFilter('StripTags')->addFilter('StringTrim') ;
        $startDate->setAttrib('placeholder', 'mm/dd/yy');
        $startDate->setAttrib('size', 51);
        $startDate->setAttrib('readOnly', 'readOnly');
        
        $duration = new Zend_Form_Element_Text('duration');
        $duration->setLabel('Ngày Kết Thúc')->addFilter('StripTags')->addFilter('StringTrim');
        $duration->setAttrib('placeholder', 'mm/dd/yy');
        $duration->setAttrib('size', 51);
        $duration->setAttrib('readOnly', 'readOnly');
        
        $owner = new Zend_Form_Element_Select('owner');
        $owner->setLabel('Tài Sản *')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
        $owner->setAttrib('style', 'width: 200px');
       	$owner->addMultiOption("SSGame","SSGame");
        $owner->addMultiOption("SSGroup","SSGroup");
        $owner->addMultiOption("WinGame","WinGame");
        $owner->addMultiOption("3S","3S");
        
        $holders = new Zend_Form_Element_Text('holders');
        $holders->setLabel('Người Ký Hợp Đồng')->addFilter('StripTags')->addFilter('StringTrim');
        $holders->setAttrib('size', 51);
        
        
        $info = new Zend_Form_Element_Textarea('info');
        $info->setLabel('Thông Tin')->addFilter('StripTags')->addFilter('StringTrim');
        $info->setAttrib('cols', 45)->setAttrib('rows', 6);
        
        $history = new Zend_Form_Element_Textarea('history');
        $history->setLabel('Lịch Sử')->addFilter('StripTags')->addFilter('StringTrim');
        $history->setAttrib('cols', 45)->setAttrib('rows', 6);
        
        $addendums = new Zend_Form_Element_Textarea('addendums');
        $addendums->setLabel('Phụ Lục')->addFilter('StripTags')->addFilter('StringTrim');
                                    
        $addendums->setAttrib('cols', 45)->setAttrib('rows', 6);
        
       
        $expire=new Zend_Form_Element_Checkbox('expire');
        $expire->setLabel('Thuê Chỗ');
        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        
        $submit->setAttrib('id','submitbutton');
         
        $this->setDecorators(array(
                                       array('viewScript',
                                       array('viewScript'=>'item/item.phtml'),
                                )));  
        $this->addElements(array ($itemName,$category, $code, $serialNumber, $priceItem, $rentItem, $priceNow, $rentEnd, $owner, $startDate, $duration, $holders, $info, $history, $addendums, $expire, $submit));
    }
}


